package com.example.flashsales.config;

import com.example.flashsales.interceptor.AdminInterceptor;
import com.example.flashsales.interceptor.RoleInterceptor;
import com.example.flashsales.interceptor.UserInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 管理员拦截器配置
 */
@Configuration
public class AdminInterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        AdminInterceptor testInterceptor = new AdminInterceptor();
        RoleInterceptor roleInterceptor = new RoleInterceptor();
        registry.addInterceptor(testInterceptor).addPathPatterns("/admin/*").excludePathPatterns("/admin/login");
        registry.addInterceptor(testInterceptor).addPathPatterns("/adminUser/*");
        registry.addInterceptor(roleInterceptor).addPathPatterns("/role/*").excludePathPatterns("/role/login");
        //GoodsController
        registry.addInterceptor(testInterceptor).addPathPatterns("/goods/addType");
        registry.addInterceptor(testInterceptor).addPathPatterns("/goods/updateType");
        registry.addInterceptor(testInterceptor).addPathPatterns("/goods/deleteType");
        registry.addInterceptor(testInterceptor).addPathPatterns("/goods/deleteGoods");
        registry.addInterceptor(testInterceptor).addPathPatterns("/goods/updateDetails");
        registry.addInterceptor(testInterceptor).addPathPatterns("/goods/addGoods");
        registry.addInterceptor(testInterceptor).addPathPatterns("/goods/updateGoodsType");
        registry.addInterceptor(testInterceptor).addPathPatterns("/goods/updatePrice");
        registry.addInterceptor(testInterceptor).addPathPatterns("/goods/updateCount");
        registry.addInterceptor(testInterceptor).addPathPatterns("/goods/updateName");
        registry.addInterceptor(testInterceptor).addPathPatterns("/goods/updateUrl");

        registry.addInterceptor(testInterceptor).addPathPatterns("/volume/*");
    }
}
